import request from '@/utils/request'
import qs from 'qs'
// 产品分类模块
export function prodCategoryList(params: { pid: number }): Pms<ICategory[]> {
    return request.get({ url: '/admin/m/prodCategory/list??pid=' + params.pid })
}

// 产品列表
export function prodPage(data: Record<string, any>): PmsPage<IProduct> {
    return request.get({
        url: '/admin/m/prod/page',
        data
    })
}

// 收藏产品列表
export function prodCollect(id: string): Pms<null> {
    return request.post({ url: `/admin/m/prod/collect/${id}` })
}

// 最近搜索关键词
export function userHistorySearchRecent(data: any): Pms<IHistorySearch[]> {
    return request.get({ url: '/admin/m/userHistorySearch/recent', data })
}

// 删除历史搜索
export function userHistorySearchDelete(id: string, type: string): Pms<null> {
    return request.delete({ url: `/admin/m/userHistorySearch/delete?id=${id}&type=${type}` })
}

// 热搜
export function userHistorySearchPopular(data: any): Pms<IHotSearch[]> {
    return request.get({ url: '/admin/m/userHistorySearch/popular', data })
}

// 产品详情
export function prodDetail(id: string): Pms<IProductDetail> {
    return request.get({ url: `/admin/m/prod/${id}` })
}

// 获取三眼狐产品详情
export const getProductFormSyhApi = (id: string): Pms<IProductDetail> => {
    return request.get({ url: `/admin/m/prod/syh/${id}` })
}

// 获取评价分页
export function prodEvaluatePage(data: Record<string, any>): PmsPage<IComment> {
    return request.get({ url: '/admin/m/prodEvaluate/page', data })
}

// 结算-生成订单信息
export function orderConfirm(data: Record<string, any>): Pms<ICheckoutResponse> {
    return request.post({ url: '/admin/m/order/confirm', data })
}

// 提交订单-返回订单id集合
export function orderSubmit(data: Record<string, any>) {
    return request.post({ url: '/admin/m/order/submit', data })
}

// 订单详情
export function orderDetail(orderId: string) {
    return request.get({ url: `/admin/m/order/detail/${orderId}` })
}

// 以图搜索产品
export const searchProdByImgApi = (formData: any) => {
    return request.post({
        url: '/admin/m/prod/search/image/pic',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}
